package pta.test0809.形状继承;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Shape> list = new ArrayList<>();
        ArrayList<String> list1 = new ArrayList<>();
        int n = sc.nextInt();
        double Areasum =0;
        double Metersum =0;
        for (int i = 0; i <=n ; i++) {
            String str = sc.nextLine();
            if (str.equals("rect")){
                //changfangx
                int nextOne = sc.nextInt();
                int nextTwo = sc.nextInt();
                sc.nextLine();
                Rectangle rectangle = new Rectangle(nextOne,nextTwo);
                list.add(rectangle);
                String s =rectangle.toString();
                list1.add(s);
                Areasum += rectangle.getArea();
                Metersum += rectangle.getPerimeter();
            } else if (str.equals("cir")) {
                //yuanx
                int nextThree = sc.nextInt();
                sc.nextLine();
                Circle circle = new Circle(nextThree);
                list.add(circle);
                String s =circle.toString();
                list1.add(s);
                Areasum += circle.getArea();
                Metersum += circle.getPerimeter();
            }
        }
        System.out.println(Metersum);
        System.out.println(Areasum);
        System.out.println(list1.toString());
        for (Shape s : list) {
            System.out.println(s.getClass()+","+s.getClass().getSuperclass());
        }

    }
}
abstract class Shape{
    final double PI = 3.14;
    public abstract double getPerimeter();
    public abstract double getArea();
}
class Rectangle extends Shape{

    int length,width;
    double area,perimeter;

    @Override
    public double getPerimeter() {
        perimeter = 2*(width+length);
        return perimeter;
    }

    @Override
    public double getArea() {
        area = width*length;
        return area;
    }

    public Rectangle(int width, int length) {
        this.length = length;
        this.width = width;
    }

    @Override
    public String toString() {
        return "Rectangle [" +
                "width=" + width +
                ", length=" + length +
                ']';
    }
}
class Circle extends Shape{
    int radius;
    double area,perimeter;

    @Override
    public double getPerimeter() {
        perimeter = PI*2*radius;
        return perimeter;
    }

    @Override
    public double getArea() {
        area = PI*radius*radius;
        return area;
    }

    public Circle(int radius) {
        this.radius = radius;
    }

    @Override
    public String toString() {
        return "Circle [" +
                "radius=" + radius +
                ']';
    }
}
